#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>

void cat_child(int);

int main(int argc,char** argv)
{
  int i;
  pid_t pid;
  for(i = 0; i < 15;i++)
  {
    pid = fork();
    if(pid == 0)
    {
      break;
    }
  }
  
  if(i == 15)
  {
    struct sigaction sig,oldsig;
    sig.sa_flags = 0;
    sigemptyset(&sig.sa_mask);
    sig.sa_handler = cat_child;
    sigaction(SIGCHLD,&sig,&oldsig);
    while(1);
  }
  return 0;
}

void cat_child(int num)
{
  pid_t pid;
  while((pid = wait(NULL))!= -1)
  {
    printf("child pid is %d\n",pid);
  }
}
